package hsmgpslogger.server.DA;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import hsmgpslogger.shared.PositionInfo;

public class PositionInfoDA {
	public static void SavePositionInfo(PositionInfo info){
		PersistenceManager pm = PMF.get().getPersistenceManager();
        try {
            pm.makePersistent(info);
        } finally {
            pm.close();
        }
	}
	
	public static List<PositionInfo> GetPositionInfo(Long startAfterId){
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Query query = pm.newQuery(PositionInfo.class);
		query.setFilter("id >= startAfterIdParam");
		query.declareParameters("long startAfterIdParam");
		List<PositionInfo> response = (List<PositionInfo>) query.execute(startAfterId);
		
		ArrayList<PositionInfo> list = new ArrayList<PositionInfo>(response);
		return list;
	}
}
